import inspect
import backtrader as bt


def generate_stub(cls, filename):
    with open(filename, 'w') as f:
        f.write(f"class {cls.__name__}:\n")
        for name, obj in inspect.getmembers(cls):
            if not name.startswith('_'):
                f.write(f"    {name}: {type(obj).__name__}\n")

# 示例：生成 Strategy 类的存根
generate_stub(bt.Strategy, "backtrader_strategy.pyi")